package com.kongyz;

import com.kongyz.mp3.MediaPlayer;
import com.kongyz.mp4.AdvanceMediaPlayer;
import com.kongyz.mp4.Mp4Player;
import com.kongyz.mp4.VlcPlayer;

/**
 * @author kongyz
 * @date 2018/6/24 00:00
 * @Description:  实现适配器
 */
public class MediaAdapter implements MediaPlayer {

    AdvanceMediaPlayer advanceMediaPlayer;

    public MediaAdapter(String audioType) {
        if(audioType.equalsIgnoreCase("vlc")){
            advanceMediaPlayer=new VlcPlayer();
        }else if(audioType.equalsIgnoreCase("mp4")){
            advanceMediaPlayer=new Mp4Player();
        }
    }

    public void play(String audioType, String fileName) {
        if(audioType.equalsIgnoreCase("vlc")){
            advanceMediaPlayer.playVlc(fileName);
        }else if (audioType.equalsIgnoreCase("mp4")){
            advanceMediaPlayer.playMp4(fileName);
        }
    }
}
